<template>
  <div class="block">
  <el-timeline>
    <el-timeline-item timestamp="" placement="top" icon="el-icon-more" color="blue">
      <el-card>
        <h4>{{info.caseName}}</h4>
        <p>{{info.undertaker}} 提交于 {{info.createTime}}</p>
        <p v-if="info.status==0"><el-button type="primary" @click="update1">审核</el-button></p>
        <p v-if="info.status==1">审核通过</p>
      </el-card>
    </el-timeline-item>
    <el-timeline-item timestamp="" placement="top" icon="el-icon-success" color="blue">
      <el-card>
        <h4>{{info.caseName}}</h4>
        <p>{{info.court}} 提交于 {{info.modifyTime}}</p>
        <p v-if="info.status==1"><el-button type="primary"  @click="update2">审核</el-button></p>
        <p v-if="info.status==2">审核通过</p>
      </el-card>
    </el-timeline-item>
    <el-timeline-item timestamp="" placement="top" icon="el-icon-success" color="blue">
      <el-card>
        <h4>{{info.caseName}}</h4>
        <p v-if="info.status==2">已办结</p>
      </el-card>
    </el-timeline-item>
  </el-timeline>
</div>
</template>

<script>
export default {
  name: "submitView",
  data() {
    return {
      id: this.$route.query.id,
      info:[]
    }
  },
  created () {
    this.caseinfo();
  },
  methods: {
    caseinfo() {
      this.request.get("/case/getCaseByid",{
        params:{
          id:this.id
        }
      }).then(res => {
        console.log("---------------------");
        console.log(res);
        this.info = res.data
      })
    },
    update1(){
      this.request.post("/case/updateStatus1",this.id).then(res => {
        if(res.code === '200'){
          this.$message.success("审核通过")
          this.caseinfo();
        }else{
          this.$message.success("审核不通过")
        }
      })
    },
    update2(){
      this.request.post("/case/updateStatus2",this.id).then(res => {
        if(res.code === '200'){
          this.$message.success("审核通过")
          this.caseinfo();
        }else{
          this.$message.success("审核不通过")
        }
      })
    }
  },

}
</script>

<style>

</style>